package com.loe.ui.quickjs

import com.loe.ui.page.UiPage
import com.quickjs.JSContext

fun JSContext.initConst()
{
    UiPage.classMap.keys.forEach()
    { key ->
        set(key, key)
    }

    executeScript(
        """
    class Page{}
    class Activity{}
    class Dialog{}
    function createUI(ui) { return ui }

    const
       m = "m",
       w = "w",
       h = "h",
       v = "v",

       Bg = {
          ripple: "ripple",
          rippleCircle: "rippleCircle",
          rippleWhite: "rippleWhite",
       },
       EditType = {
          text: "text",
          pass: "pass",
          number: "number",
          decimal: "decimal",
          textCode: "textCode",
       },
       Direct = {
          left: "left",
          top: "top",
          right: "right",
          bottom: "bottom",
       },
       Gravity = {
          left: "l",
          top: "t",
          right: "r",
          center: "c",
          centerH: "ch",
          centerV: "cv",
          centerLeft: "cl",
          centerTop: "ct",
          centerRight: "cr",
          centerBottom: "cb",
          rightTop: "rt",
          rightBottom: "rb",
          leftTop: "lt",
          leftBottom: "lb",
       },
       Ellipsis = {
          start: "start",
          middle: "middle",
          end: "end",
          marquee: "marquee",
       },
       Scale = {
          fit_center: "fit_center",
          fit_xy: "fit_xy",
          center_crop: "center_crop",
          center_inside: "center_inside",
          center: "center",
          fit_start: "fit_start",
          fit_end: "fit_end",
          matrix: "matrix",
       },
       TextStyle = {
          bold: "bold",
          delete: "delete",
          under: "under",
          normal: "normal",
       }
       
    const FlexDirection = {
       row: "row",
       column: "column",
       rowReverse: "rowReverse",
       columnReverse: "columnReverse",
    }

    const ShowDivider = {
       middle: "middle",
       end: "end",
       none: "none",
       beginning: "beginning",
    }

    const AlignItems = {
       flexStart: "flexStart",
       flexEnd: "flexEnd",
       center: "center",
       stretch: "stretch",
       baseline: "baseline",
    }

    const AlignContent = {
       flexStart: "flexStart",
       flexEnd: "flexEnd",
       center: "center",
       stretch: "stretch",
       spaceAround: "spaceAround",
       spaceBetween: "spaceBetween",
    }

    const JustifyContent = {
       flexStart: "flexStart",
       flexEnd: "flexEnd",
       center: "center",
       spaceEvenly: "spaceEvenly",
       spaceAround: "spaceAround",
       spaceBetween: "spaceBetween",
    }

    const FlexWrap = {
       wrap: "wrap",
       nowrap: "nowrap",
       wrapReverse: "wrapReverse",
    }

    const AlignSelf = AlignItems
    
    """.trimIndent(), "init.js"
    )

    jsColor = JSColor(this)
    set("Color", jsColor)
}